var yuan = {
    username: "yuan",
    age: 22,
    wx: "u82d1660a",
    fn:function (){
        console.log("fn ...")
    }
}

var rain = {
    username: "rain",
    age: 12,
    wx: "u82d1660a",
    fn:function (){
        console.log("fn ...")
    }
}

yuan = new Proxy(yuan, {
    get(target, p, receiver) {
        console.log(target, "查询了属性", p)
        // return window['username'];/// 这里如果这样写. 有递归风险的...
        // return Reflect.get(...arguments);
        return Reflect.get(target, p);
    },
    set(target, p, value, receiver) {
        console.log(target, "设置了属性", p, "值为：", value)
        Reflect.set(target, p, value);
    }
});

rain = new Proxy(rain, {
    get(target, p, receiver) {
        console.log(target, "查询了属性", p)
        // return window['username'];/// 这里如果这样写. 有递归风险的...
        // return Reflect.get(...arguments);
        return Reflect.get(target, p);
    },
    set(target, p, value, receiver) {
        console.log(target, "设置了属性", p, "值为：", value)
        Reflect.set(target, p, value);
    }
});



//  源码执行
console.log(yuan.username)
console.log(yuan.wx)
yuan.age = 18
console.log(yuan.age)
// console.log(yuan.wx)
// console.log(yuan.fn())

console.log(rain.age)
console.log(rain.username)
console.log(rain.fn())